package cn.yuanqiao.web.controller.archive.detection;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import cn.yuanqiao.common.annotation.Log;
import cn.yuanqiao.common.enums.BusinessType;

import cn.yuanqiao.archive.detection.domain.DetectionItem;
import cn.yuanqiao.archive.detection.service.IDetectionItemService;
import cn.yuanqiao.common.web.controller.BaseController;
import cn.yuanqiao.common.core.domain.AjaxResult;
import cn.yuanqiao.common.utils.poi.ExcelUtil;
import cn.yuanqiao.common.web.page.TableDataInfo;

/**
 * 配置项Controller
 * 
 * @author xy
 * @date 2023-08-08
 */
@RestController
@RequestMapping("/archive/detectionItem")
public class DetectionItemController extends BaseController
{
    @Autowired
    private IDetectionItemService detectionItemService;

    /**
     * 查询配置项列表
     */
/*
    @PreAuthorize("@ss.hasPermi('archive:DetectionItem:list')")
*/
    @GetMapping("/list")
    public TableDataInfo list(DetectionItem detectionItem)
    {
        startPage();
        List<DetectionItem> list = detectionItemService.selectDetectionItemList(detectionItem);
        return getDataTable(list);
    }

    /**
     * 导出配置项列表
     */
    @PreAuthorize("@ss.hasPermi('archive:DetectionItem:export')")
    @Log(title = "配置项", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DetectionItem detectionItem)
    {
        List<DetectionItem> list = detectionItemService.selectDetectionItemList(detectionItem);
        ExcelUtil<DetectionItem> util = new ExcelUtil<DetectionItem>(DetectionItem.class);
        util.exportExcel(response, list, "配置项数据");
    }

    /**
     * 获取配置项详细信息
     */
    @PreAuthorize("@ss.hasPermi('archive:DetectionItem:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(detectionItemService.selectDetectionItemById(id));
    }

    /**
     * 新增配置项
     */
    @PreAuthorize("@ss.hasPermi('archive:DetectionItem:add')")
    @Log(title = "配置项", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DetectionItem detectionItem)
    {
        return toAjax(detectionItemService.insertDetectionItem(detectionItem));
    }

    /**
     * 修改配置项
     */
    @PreAuthorize("@ss.hasPermi('archive:DetectionItem:edit')")
    @Log(title = "配置项", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DetectionItem detectionItem)
    {
        return toAjax(detectionItemService.updateDetectionItem(detectionItem));
    }

    /**
     * 删除配置项
     */
    @PreAuthorize("@ss.hasPermi('archive:DetectionItem:remove')")
    @Log(title = "配置项", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(detectionItemService.deleteDetectionItemByIds(ids));
    }
}
